using Common.DEncrypt;
using DukeyTbker.Properties;
using ns0;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;


namespace DukeyTbker
{
 
    public class Register : Form
    {
        private Button button1;
        private Button button2;
        private dukeyauth dukeyauth_0;
        private IContainer icontainer_0;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private Label label5;
        private LinkLabel linkLabel1;
        private LinkLabel linkLabel2;
        private string string_0 = "";
        private string string_1 = "error";
        private TextBox txtEmail;
        private TextBox txtRegKey;
        private TextBox txtSignKey;

        public Register(string string_2)
        {
            this.InitializeComponent();
            this.string_0 = string_2;
            this.txtSignKey.Text = string_2;
            this.txtEmail.Text = Settings.Default.email;
            this.txtRegKey.Text = Settings.Default.regkey;
            this.dukeyauth_0 = new dukeyauth();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = false;
            this.button1.Text = "正在注册...";
            if (this.txtRegKey.Text.Trim() != Common.DEncrypt.DEncrypt.Encrypt(this.string_0))
            {
                try
                {
                    string str = this.txtEmail.Text.Trim();
                    if (string.IsNullOrEmpty(str))
                    {
                        MessageBox.Show("请输入购买时的email账号!");
                        this.button1.Enabled = true;
                        return;
                    }
                    str = str.Replace(".", "-");
                    switch (this.dukeyauth_0.AuthUserTbkSoft(str, this.string_0, this.txtRegKey.Text.Trim(), "f897ed3a-fb14-4ad1-80a2-b69973743230", ref this.string_1, 110))
                    {
                        case "expire1111":
                            base.Hide();
                            MessageBox.Show("你的产品已超过使用期,请续费!联系qq:1902976602");
                            Environment.Exit(0);
                            break;

                        case "nouser111":
                            MessageBox.Show("没有查询到该账户的授权信息,请购买,或者联系qq:1902976602");
                            this.button1.Enabled = true;
                            return;
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show("获取账户失败,请联系qq:1902976602 " + exception.Message);
                    return;
                }
                base.DialogResult = DialogResult.OK;
                Settings.Default.regkey = this.txtRegKey.Text.Trim();
                Settings.Default.email = this.txtEmail.Text.Trim();
                Settings.Default.Save();
                MessageBox.Show("注册成功,请重新启动软件!");
                Environment.Exit(0);
            }
            else
            {
                MessageBox.Show("注册码不正确!");
                Environment.Exit(0);
                this.button1.Enabled = true;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.txtSignKey.SelectAll();
            this.txtSignKey.Copy();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer_0 != null))
            {
                this.icontainer_0.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.txtRegKey = new TextBox();
            this.label2 = new Label();
            this.linkLabel1 = new LinkLabel();
            this.label3 = new Label();
            this.button1 = new Button();
            this.label4 = new Label();
            this.txtSignKey = new TextBox();
            this.button2 = new Button();
            this.txtEmail = new TextBox();
            this.label1 = new Label();
            this.label5 = new Label();
            this.linkLabel2 = new LinkLabel();
            base.SuspendLayout();
            this.txtRegKey.Location = new Point(0x10, 0x68);
            this.txtRegKey.Name = "txtRegKey";
            this.txtRegKey.Size = new Size(0x14b, 0x15);
            this.txtRegKey.TabIndex = 1;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(14, 0x58);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x5f, 12);
            this.label2.TabIndex = 2;
            this.label2.Text = "直接输入注册码:";
            this.linkLabel1.AutoSize = true;
            this.linkLabel1.Location = new Point(14, 0x98);
            this.linkLabel1.Name = "linkLabel1";
            this.linkLabel1.Size = new Size(0x95, 12);
            this.linkLabel1.TabIndex = 3;
            this.linkLabel1.TabStop = true;
            this.linkLabel1.Text = "没有注册码?我要立即购买!";
            this.linkLabel1.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
            this.label3.AutoSize = true;
            this.label3.ForeColor = SystemColors.ControlDarkDark;
            this.label3.Location = new Point(0xb6, 0x98);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0xf5, 12);
            this.label3.TabIndex = 4;
            this.label3.Text = "如果支付遇到问题,请联系作者qq:1902976602\r\n";
            this.button1.Location = new Point(0x161, 0x67);
            this.button1.Name = "button1";
            this.button1.Size = new Size(0x4b, 0x17);
            this.button1.TabIndex = 5;
            this.button1.Text = "点此注册";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new EventHandler(this.button1_Click);
            this.label4.AutoSize = true;
            this.label4.Location = new Point(14, 0x35);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x2f, 12);
            this.label4.TabIndex = 2;
            this.label4.Text = "机器码:";
            this.txtSignKey.Location = new Point(0x43, 0x30);
            this.txtSignKey.Name = "txtSignKey";
            this.txtSignKey.Size = new Size(0xc9, 0x15);
            this.txtSignKey.TabIndex = 1;
            this.button2.Location = new Point(0x110, 0x2f);
            this.button2.Name = "button2";
            this.button2.Size = new Size(0x4b, 0x17);
            this.button2.TabIndex = 5;
            this.button2.Text = "复制";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new EventHandler(this.button2_Click);
            this.txtEmail.Location = new Point(0x43, 12);
            this.txtEmail.Name = "txtEmail";
            this.txtEmail.Size = new Size(0xc9, 0x15);
            this.txtEmail.TabIndex = 1;
            this.label1.AutoSize = true;
            this.label1.Location = new Point(14, 0x11);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x29, 12);
            this.label1.TabIndex = 2;
            this.label1.Text = "Email:";
            this.label5.AutoSize = true;
            this.label5.ForeColor = SystemColors.ControlDarkDark;
            this.label5.Location = new Point(14, 0xb1);
            this.label5.Name = "label5";
            this.label5.Size = new Size(0x197, 12);
            this.label5.TabIndex = 6;
            this.label5.Text = "本软件支持64位操作系统和win8!重装系统可能导致机器码改变,请自助更换!";
            this.linkLabel2.AutoSize = true;
            this.linkLabel2.LinkColor = Color.Red;
            this.linkLabel2.Location = new Point(0xd8, 130);
            this.linkLabel2.Name = "linkLabel2";
            this.linkLabel2.Size = new Size(0x83, 12);
            this.linkLabel2.TabIndex = 7;
            this.linkLabel2.TabStop = true;
            this.linkLabel2.Text = "注册码不正确?点此更换";
            this.linkLabel2.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            //base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x1c3, 0xc6);
            base.Controls.Add(this.linkLabel2);
            base.Controls.Add(this.label5);
            base.Controls.Add(this.button2);
            base.Controls.Add(this.button1);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.linkLabel1);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.txtEmail);
            base.Controls.Add(this.txtSignKey);
            base.Controls.Add(this.txtRegKey);
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "Register";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "温馨提示                                           →官方www.mou18.com";
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("http://www.dukeycms.com/tkjysoftsignkey_" + this.string_0 + ".html");
        }

        private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("http://www.dukeycms.com/tkjysoftregistercode_" + this.string_0 + ".html");
        }
    }
}

